import java.nio.*;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.input.*;
import org.lwjgl.openal.AL10;
import org.lwjgl.opengl.*;
import org.lwjgl.util.WaveData;

public class QuizABC{
	public static void main(String[] args)
	{
		//loadALData();
		try {
			Display.setDisplayMode(new DisplayMode(800, 600));
			Display.create();
		} catch (LWJGLException e) {
			e.printStackTrace();
		}
		//clear
		GL11.glMatrixMode(GL11.GL_PROJECTION);
		GL11.glLoadIdentity();
		GL11.glOrtho(0, 800, 0, 600, 1, -1);
		GL11.glMatrixMode(GL11.GL_MODELVIEW);
		//view!!!
		Mouse.setCursorPosition(800/2, 600/2);
		int oldx=-1, oldy=-1;
		while(!Display.isCloseRequested())
		{
			boolean mouse0release=true;
			if(Mouse.isButtonDown(0) && mouse0release==true)
			{
				int x=Mouse.getX(), y=Mouse.getY();
				if(!(x==oldx && y==oldy))
				{
					System.out.println("X:"+x+"     Y:"+y);
					//GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
					GL11.glColor3f(0.5f,0.5f,1.0f);
					GL11.glBegin(GL11.GL_POINTS);
						GL11.glVertex2f(x,y);
					GL11.glEnd();
					oldx=x;
					oldy=y;
				}
			}
			while (Keyboard.next())
			{
				if(Keyboard.getEventKeyState())
				{
					if(Keyboard.getEventKey() == Keyboard.KEY_A)
						System.out.println("A pressed");
				}
				else
				{
					if(Keyboard.getEventKey() == Keyboard.KEY_A)
						System.out.println("A Key Released");
				}
			}
			//Input
			//GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
			GL11.glColor3f(0.5f,0.5f,1.0f);
			GL11.glBegin(GL11.GL_QUADS);
				GL11.glVertex2f(28,544);
				GL11.glVertex2f(28+50,544);
				GL11.glVertex2f(28+50,544+50);
				GL11.glVertex2f(28,544+50);
			GL11.glEnd();
			Display.update();
		}
		Display.destroy();
	}
}